<%--
  Created by IntelliJ IDEA.
  User: 沸羊羊
  Date: 2022/11/1
  Time: 14:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>产品设计添加</title>
</head>
<body>
<form id="myFormC">
    <div class="container" style="width: 1210px;height: 600px;border: #EEEEEE solid 1px;background: #EEEEEE">
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">你正在做的业务：产品设计--产品档案管理--产品档案登记</span><br><br><br>
        <%--提交和清除按钮框--%>
        <input type="submit" value="清除" style="background: #CADEF6;float: right;width: 51px;height: 34px; margin-top: -37px;margin-right: 41px;">
        <input type="submit" value="提交" style="background: #CADEF6;float: right;width: 51px;height: 34px; margin-top: -37px;margin-right: 103px;">
        <div class="container" style="width: 1100px;height: 444px;border: black solid 2px">
            <div style="width: 1080px;height: 27px;border: blue solid 1px;background: #58A7EC">
                <span style="color: white">主信息</span>
            </div>
            <div class="row">
                <div style="width: 500px;" class="col-md-6">
                    <table border="0px" >
                        <tr>
                            <td style="height: 30px;width:167px; text-align: right;background: #D0E4FC"><span style="color: red">*</span>产品名称</td>
                            <td><input type="text" style="width: 300px;" id="productnameC" name="productname" required></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span style="color: red">*</span>I级分类</td>
                            <td>
                                <select style="width: 203px;" id="firstkindidC" name="firstkindid" required onclick="one()">
                                    <option value=""></option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span style="color: red">*</span>III级分类</td>
                            <td>
                                <select style="width: 203px;" id="thirdkindidC" name="thirdkindid" required onclick="two()">
                                    <option value=""></option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">用途类型</td>
                            <td>
                                <select style="width: 203px;" id="typeC" name="type">
                                    <option value="">------------请选择-------------</option>
                                    <option value="Y001-1" selected>商品</option>
                                    <option value="Y001-2">物料</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">计量单位</td>
                            <td><input type="text"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span class="glyphicon glyphicon-usd"></span><span style="color: red">*</span>市场单价(元)</td>
                            <td><input type="text" id="listpriceC" name="listprice" required></td>
                        </tr>
                    </table>
                </div>
                <%--二--%>
                <div class="col-md-6">
                    <table border="0px" >
                        <tr>
                            <td style="height: 30px;width:167px; text-align: right;background: #D0E4FC">制造商</td>
                            <td><input type="text" style="width: 300px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span style="color: red">*</span>II级分类</td>
                            <td>
                                <select style="width: 203px;" id="secondkindidC" name="secondkindid" required>
                                    <option value=""></option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">产品简称</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">档次级别</td>
                            <td>
                                <select style="width: 203px;" id="productclassC" name="productclass" required>
                                    <option value="">------------请选择-------------</option>
                                    <option value="D001-1" selected>高档</option>
                                    <option value="D001-2">中档</option>
                                    <option value="D001-3">低档</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">计量值</td>
                            <td><input type="text"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span class="glyphicon glyphicon-usd"></span><span style="color: red">*</span>计划成本单价(元)</td>
                            <td><input type="text" id="costpriceC" name="costprice" required    ></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div style="width: 1080px;height: 27px;border: blue solid 1px;background: #58A7EC">
                <span style="color: white">辅助信息</span>
            </div>

            <%--三和四个表格--%>
            <div class="row">
                <div style="width: 500px;" class="col-md-6">
                    <table border="0px" >
                        <tr>
                            <td style="height: 30px;width:167px; text-align: right;background: #D0E4FC">保修期</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">替代品编号</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">单位</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">供应商集合</td>
                            <td>
                                <textarea style="width: 302px;height: 77px;">

                                </textarea>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span class="glyphicon glyphicon-user"></span>登记人</td>
                            <td><input type="text" value="${username}"></td>
                        </tr>
                    </table>
                </div>
                <%--四--%>
                <div class="col-md-6">
                    <table border="0px" >
                        <tr>
                            <td style="height: 30px;width:167px; text-align: right;background: #D0E4FC">替代品名称</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">生命周期(年)</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">产品经理</td>
                            <td><input type="text" style="width: 203px;"></td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC">产品描述</td>
                            <td>
                                <textarea style="width: 302px;height: 77px;">

                                </textarea>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 30px;text-align: right;background: #D0E4FC"><span class="glyphicon glyphicon-dashboard"></span>建档时间</td>
                            <td><input type="text" id="wdbb" readonly></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
</form>
    <script>


        $(function (){
            $.get("queryCellByDate.action",function (data) {
                $("#wdbb").val(data.datetime);
            },"json")

            //给一级分类下拉框赋值
            $.ajax({
                url:"queryFileSel.action",
                type:"post",
                dataType:"json",
                success:function (data){
                    for(var i=0; i<data.length;i++){
                        var op=$("<option></option>")
                        op.val(data[i].firstkindid+','+data[i].firstkindname);
                        op.text(data[i].firstkindname);
                        $("#firstkindidC").append(op);
                    }
                }
            })

            $("#myFormC").validate({
                messages:{
                    productname:"产品不能为空",
                    firstkindid:"I级分类请选择一个状态",
                    secondkindid:"II级分类请选择一个状态",
                    thirdkindid:"III级分类请选择一个状态",
                    listprice:"市场单价不能为空",
                    costprice:"计划成本单价不能为空",
                },
                submitHandler:function (form){
                    $("#myFormC").ajaxSubmit({
                        url:"addFile.action",
                        type:"post",
                        datatype:"json",
                        success:function (data){
                            alert(data.msg);
                            $("#tab1").closeTabs("产品档案登记")
                        }
                    })
                }
            })
        })

        function II() {
            //给二级分类下拉框赋值
            $.ajax({
                url:"queryFileSel.action",
                type:"post",
                dataType:"json",
                success:function (data){
                    for(var i=0; i<data.length;i++){
                        var op=$("<option></option>")
                        op.val(data[i].secondkindid+','+data[i].secondkindname);
                        op.text(data[i].secondkindname);
                        $("#secondkindidC").append(op);
                    }
                }
            })
        }

        function III() {
            //给三级分类下拉框赋值
            $.ajax({
                url:"queryFileSel.action",
                type:"post",
                dataType:"json",
                success:function (data){
                    for(var i=0; i<data.length;i++){
                        var op=$("<option></option>")
                        op.val(data[i].thirdkindid+','+data[i].thirdkindname);
                        op.text(data[i].thirdkindname);
                        $("#thirdkindidC").append(op);
                    }
                }
            })
        }

        //一级
        function one() {
            if($("#firstkindidC").val()==""){//一级是空设置一级二级为失效  值清空
                $("#secondkindidC")[0].length=1;
                $("#thirdkindidC")[0].length=1;
            }else{
                II();
            }

        }

        //二级
        function two() {
            if($("#secondkindidC").val()==""){//二级为空三级失效  值清空
                $("#thirdkindidC")[0].length=1;
            }else{
                III();
            }
        }
    </script>

</body>
</html>
